package data.set.implementation;

import java.util.ArrayList;

import data.set.OfflineSet;
import data.set.OfflineSetIterator;


/**
 * Builds an OfflineSetiterator from an OfflineSet and a list of Ids
 * @author guillaumes
 *
 * @param <X> : the type of the offlinesetiterator's data
 */
public class OfflineSetIterator_FromIds<X> implements OfflineSetIterator<X>
{
	private ArrayList<Integer> ids;
	private OfflineSet<X> set;
	private int currentindex;
	
	/**
	 * 
	 * @param ids : the list of the ids
	 * @param set : offlineset
	 */
	public OfflineSetIterator_FromIds(ArrayList<Integer> ids,OfflineSet<X> set)
	{
		this.ids=ids;
		this.set=set;
		currentindex=-1;
	}
	
	public int getCurrentId() {
		return(ids.get(currentindex));
	}

	
	public X getCurrentObject() {
		return(set.getObject(getCurrentId()));
	}

	
	public boolean hasNext() {
		return (currentindex<ids.size()-1);
	}

	
	public void next() {
		currentindex++;
	}

}
